﻿using Base.Structure.Application.Dto;
using Base.Structure.Application.Interfaces;
using Base.Structure.Infrastructure.Entities;
using Base.Structure.Infrastructure.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Base.Structure.Application.Services
{
    public class UserService : IUserService
    {
        private readonly IUserRepository _userRepository;

        public UserService(IUserRepository userRepository)
        {
            _userRepository = userRepository;
        }

        public async Task<UserDto> GetUserByIdAsync(int id)
        {
            var user = await _userRepository.GetUserByIdAsync(id);
            return new UserDto { Id = user.Id, Name = user.Name };
        }

        public async Task<int> CreateUserAsync(UserDto userDto)
        {
            var user = new User { Name = userDto.Name };
            return await _userRepository.AddUserAsync(user);
        }
    }
}
